---
id: 65670d1ef177e7e2b76d9528
title: Step 17
challengeType: 20
dashedName: step-17
---

# --description--

The `if` and `else` statements you created in the previous steps will assign elements to the sorted array. 

Each element assigned to the sorted array takes up an index in the list. So you have to move to the next index without an element.

Below the `if`/`else` block, but still within the `while` loop increment `sorted_index` by 1. This should not be in the body of the `if` or `else` statement

# --hints--

You should increment the current value of `sorted_index` by 1.

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /^\s{8}sorted_index\s*(\+=\s*1|=\s*sorted_index\s*\+\s*1)/m);
  }
})
```

# --seed--

## --seed-contents--

```py
def merge_sort(array):
    
    middle_point = len(array) // 2
    left_part = array[:middle_point]
    right_part = array[middle_point:]

    merge_sort(left_part)
    merge_sort(right_part)

    left_array_index = 0
    right_array_index = 0
    sorted_index = 0

--fcc-editable-region--
    while left_array_index < len(left_part) and right_array_index < len(right_part):
        if left_part[left_array_index] < right_part[right_array_index]:
            array[sorted_index] = left_part[left_array_index]
            left_array_index += 1
        else:
            array[sorted_index] = right_part[right_array_index]
            right_array_index += 1
--fcc-editable-region--
```
